package battleship.model;
import java.util.*;
/**
 * Places all the ships on the specified grid (thats all that this class is used for)
 * @author Cameron McLeod
 * @version 1.0
 */
public class ShipPlace {

	Random generator = new Random();
	int x;
	int y;
	int dir;
	
	Carrier Carrier = new Carrier();
	Destroyer Destroyer = new Destroyer();
	Submarine Submarine = new Submarine();
	patrol_boat patrol_boat = new patrol_boat();
	Battleship Battleship = new Battleship();
	/**
	 * Places all the ships on the specified grid
	 * @param grid
	 */
	public ShipPlace(Grid grid) {
		do{
			x = generator.nextInt(10);
			y = generator.nextInt(10);
			dir = generator.nextInt(4);
		}while(!Carrier.Place(x, y, dir, grid));			
		
		do{
			x = generator.nextInt(10);
			y = generator.nextInt(10);
			dir = generator.nextInt(4);
		}while(!Destroyer.Place(x, y, dir, grid));

		do{
			x = generator.nextInt(10);
			y = generator.nextInt(10);
			dir = generator.nextInt(4);
		}while(!Submarine.Place(x, y, dir, grid));
		
		do{
			x = generator.nextInt(10);
			y = generator.nextInt(10);
			dir = generator.nextInt(4);
		}while(!patrol_boat.Place(x, y, dir, grid));
		
		do{
			x = generator.nextInt(10);
			y = generator.nextInt(10);
			dir = generator.nextInt(4);
		}while(!Battleship.Place(x, y, dir, grid));
	}
}